package moa.learners;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import moa.MOAObject;
import moa.core.Measurement;
import moa.learners.prefix.AlgoPrefixSpan;
import moa.learners.prefix.Item;
import moa.learners.prefix.Itemset;
import moa.learners.prefix.Sequence;
import moa.learners.prefix.SequenceDatabase;
import moa.options.IntOption;
import moa.structure.Node;
import moa.structure.SequenceApparition;
import moa.structure.Transaction;
import weka.core.Instance;



public class PrefixSpan extends AbstractLearner{


	
	//private Sequence sequence;
	
	//private Itemset itemset;
	
	private SequenceDatabase sequenceDatabase;
	
	private AlgoPrefixSpan algo;
	
	public IntOption minSupportOption = new IntOption("minSupport", 's',
			"Minimum support threshold.", 50, 0,
			100);
	
	
	//private final List<Sequence> sequences = new ArrayList<Sequence>();
	
	@Override
	public void getModelDescription(StringBuilder out, int indent) {
		//sequenceDatabase.print();
		System.out.println("Run Algorithm");
		algo.runAlgorithm(sequenceDatabase);
		algo.printStatistics(sequenceDatabase.size(),out);
	}

	@Override
	protected Measurement[] getModelMeasurementsImpl() {
		// execute the algorithm
		return null;
	}

	@Override
	public void resetLearningImpl() {
		sequenceDatabase = new SequenceDatabase(); 
		// Create an instance of the algorithm with minsup = 50 %
		algo = new AlgoPrefixSpan(0.01*minSupportOption.getValue()); 
		
	}

	@Override
	public void trainOnInstanceImpl(Instance inst) {
		sequenceDatabase.addSequenceInstance(inst);
		System.out.println("Sequence added");
	}

	@Override
	public MOAObject getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isRandomizable() {
		// TODO Auto-generated method stub
		return false;
	}


}
